package com.sh.data.engine.domain.integration.offline.model.domain;

import com.sh.data.engine.repository.dao.integration.offline.entity.OfflineSyncEntity;
import lombok.Builder;
import lombok.Data;
import lombok.experimental.Tolerate;

import java.util.Date;
import java.util.List;

@Data
public class OfflineSyncPageDomain {

    /**
     * 主键
     */
    private Long id;

    /**
     * 任务名称
     */
    private String taskName;

    /**
     * 来源数据源类型
     */
    private String source;

    /**
     * 目标数据源类型
     */
    private String target;

    private Long sourceDsId;

    /**
     * 目标数据源id
     */
    private Long targetDsId;

    private Integer taskStatus;

    private Integer taskRunStatus;

    private int scheduleUnit;

    private Date startTime;

    private Date endTime;

    private String creator;

//    protected Long creatorId;
    protected String creatorId;

    private String scheduleInfo;

    //  private List<OfflineSyncEntity.TableMapping> tableMappings;

    private String sourceTable;

    private String targetTable;

    private List<OfflineSyncEntity.FieldMapping> fieldMappings;

    private OfflineSyncSchedule schedule;

    private Date publishTime;

    private Date createTime;

    @Data
    @Builder(toBuilder = true)
    public static class TableMapping {

        private String mappingId;

        /*来源表*/
        private String sourceTable;

        /*目标表*/
        private String targetTable;
    }

    @Data
    @Builder(toBuilder = true)
    public static class OfflineSyncSchedule {

        /*调度状态 0-未冻结 1-冻结"*/
        private Integer status;

        /*生效开始时间*/
        private Date effectiveDateStart;

        /*生效结束时间*/
        private Date effectiveDateEnd;

        /*调度周期 0-月 1-周 2-天 3-小时 4-分钟*/
        private Integer cycle;

        /*执行开始时间的小时*/
        private String startTimeHour;

        /*执行开始时间的分钟*/
        private String startTimeMin;

        /*执行结束时间的小时*/
        private String endTimeHour;

        /*执行结束时间的分钟*/
        private String endTimeMin;

        /*
          月、周为执行日期 ，小时、分钟为执行间隔
        */
        private String execPoint;

        /*跨周期依赖 0-不依赖上一周期 1-等待上一周期结束*/
        private Integer cycleDependence;

        @Tolerate
        public OfflineSyncSchedule() {
        }
    }
}
